<?php

class Stage
{
	private $id;
	private $van;
	private $tot;
	private $student1;
	private $student2;
	private $docent;
	private $bedrijfsbegeleider;
	private $type;
	private $status;
	
	private $wsdl;
	private $sugar_client;
	
	/* Constructor */
	public function __Construct($arg_wsdl)
	{
		$this->wsdl = $arg_wsdl;
		$this->sugar_client = new nusoapclient($this_wsdl, true);
	}
	
	/* InitData */
	public function setData($arg_van, $arg_tot, $arg_student1, $arg_student2, $arg_docent, $arg_bedrijfsbegeleider, $arg_type)
	{
		$this->id = NULL;
		$this->van = $arg_van;
		$this->tot = $arg_tot;
		$this->student1 = $arg_student1;
		$this->student2 = $arg_student2;
		$this->docent = $arg_docent;
		$this->bedrijfsbegeleider = $arg_bedrijfsbegeleider;
		$this->type = $arg_type;
		$this->status = "Open";
	}
	
	/* Set Methoden */
	public function setId($arg_id)
	{
		$this->id = $arg_id;
	}
	
	public function setVan($arg_van)
	{
		$this->van = $arg_van;
	}
	
	public function setTot($arg_tot)
	{
		$this->tot = $arg_tot;
	}
	
	public function setStudent1($arg_student1)
	{
		$this->student1 = $arg_student1;
	}
	
	public function setStudent2($arg_student2)
	{
		$this->student2 = $arg_student2;
	}
	
	public function setDocent($arg_docent)
	{
		$this->docent = $arg_docent;
	}
	
	public function setBedrijfsbegeleider($arg_bedrijfsbegeleider)
	{
		$this->bedrijfsbegeleider = $arg_bedrijfsbegeleider;
	}
	
	public function setStatus($arg_status)
	{
		$this->status = $arg_status;
	}
	
	public function setType($arg_type)
	{
		$this->type = $arg_type;
	}
	
	/* Get Methoden */
	public function getId()
	{
		return $this->id;
	}
	
	public function getVan()
	{
		return $this->van;
	}
	
	public function getTot()
	{
		return $this->tot;
	}
	
	public function getStudent1()
	{
		return $this->student1;
	}
	
	public function getStudent2()
	{
		return $this->student2;
	}
	
	public function getBedrijfsbegeleider()
	{
		return $this->bedrijfsbegeleider;
	}
	
	public function getDocent()
	{
		return $this->docent;
	}
	
	public function getStatus()
	{
		return $this->status;
	}
	
	public function getType()
	{
		return $this->type;
	}
	
	/* Other */
	public function save()
	{
		$session_id = $_SESSION['session'];
		
		//Nog aan te passen
		$set_entry_params = array(
	    	'session' => $session_id,
	        'module_name' => 'st_Stage',
	        'name_value_list'=>array(
	                           	 	array('name'=>'id','value'=>$this->getId()),
									array('name'=>'name','value'=>'Stage'),
	                           		array('name'=>'fromd','value'=>$this->getVan()),
									array('name'=>'tilld','value'=>$this->getTot()),
									array('name'=>'student1','value'=>$this->getStudent1()),
									array('name'=>'student2','value'=>$this->getStudent2()),
									array('name'=>'bedrijf_id','value'=>$this->getBedrijfsbegeleider()),
									array('name'=>'docent_id','value'=>$this->getDocent()),
									array('name'=>'stagetype','value'=>$this->getType()),
									array('name'=>'status','value'=>$this->getStatus())
	                          		)
	                          );
		
		$result = $this->sugar_client->call('set_entry',$set_entry_params);

		if($result['error']['name']== "No Error")
		{
			$this->id = $result['id'];
			return $result['id'];
		}
		else
		{
			return $result['error']['name'];
		}
	}
}

?>